//
//  CmtRecTableViewCell.m
//  Products_B
//
//  Created by lanou on 16/5/28.
//  Copyright © 2016年 朋学友. All rights reserved.
//

#import "CmtRecTableViewCell.h"
#import "ScrollViewManager.h"
#import "CmtRECModel.h"
#import "CmtRECTalent.h"
#import "CmtRECMarrow.h"
#import "CmtRECTopics.h"
#import "ImageUpLabel.h"

@interface CmtRecTableViewCell ()
@property(nonatomic,strong)ImageUpLabel *imageUpLabel;
@property(nonatomic,assign)int index;
@end


@implementation CmtRecTableViewCell


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.imageUpLabel = [[ImageUpLabel alloc]initWithFrame:CGRectMake(10, 20, 250, 30) image:[UIImage imageNamed:@"Cmt3.png"] textLabel:nil tapAction:^(int index) {
            
        }];
        
        self.button = [UIButton buttonWithType:(UIButtonTypeCustom)];
        self.button.frame = CGRectMake(kWidth - 100, 10, 100, 30);
        [self.button setImage:[UIImage imageNamed:@"CmtRight.png"] forState:(UIControlStateNormal)];

    }
    return self;
}

//达人分区
-(void)setWithModelArray:(NSMutableArray *)modelArray TapBlock:(TapBlock) tapBlock{

        self.contentView.backgroundColor = [UIColor whiteColor];
        self.tapBlock = tapBlock;
        self.ILScrollView = [[ILScrollViewManger alloc]init];
        NSMutableArray *imageArr = [NSMutableArray arrayWithCapacity:10];
        NSMutableArray *titleArr = [NSMutableArray arrayWithCapacity:10];
        NSMutableArray *detailArr = [NSMutableArray arrayWithCapacity:10];
        for (CmtRECTalent *model in modelArray) {
            [imageArr addObject:model.head_img];
            [titleArr addObject:model.nick];
            [detailArr addObject:model.tongji_be_follow];
        }
    
       [self.ILScrollView SetScrollViewWithFrame:CGRectMake(0, 0, kWidth, kWidth / 4 + 80) viewController:self.contentView ImageLabelWithimageArray:imageArr titleTextArray:titleArr detailTextArray:detailArr tapAction:^(int index){
           self.index = index;
           self.tapBlock(self.index);
       }];
}

//精选作品
-(void)setScrollewWith:(NSMutableArray *)modelArray{
   
    self.scrollViewManger = [[SCViewManager alloc]init];
    
    NSMutableArray *imageArr = [NSMutableArray array];
    
    if ([modelArray.firstObject isKindOfClass:[CmtRECMarrow class]]) {
        for (CmtRECMarrow *model in modelArray) {
            [imageArr addObject:model.image];
        }
    }

    [self.scrollViewManger viewRepeatScrollWithPicArray:imageArr view:self.contentView frame:self.contentView.frame withImageViewFrame:CGRectMake(0, 0,self.contentView.frame.size.width / 3, self.contentView.frame.size.width / 3)];
    
    __block CmtRecTableViewCell *blockSelf = self;
    self.scrollViewManger.block = ^(int index){
        _index = index;
        blockSelf.tapIndexBlock(index);
    };
  
}

//下面的Cell
-(void)setCellWithModel:(CmtRECTopics *)model{
    
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kWidth, 50)];
    view.backgroundColor = [UIColor whiteColor];
    view.userInteractionEnabled = YES;
    
    [view addSubview:_button];
    
    self.imageUpLabel.textlabel.text = model.topic_name;
    [view addSubview:_imageUpLabel];
    
    [self.contentView addSubview:view];
    
    self.scrollViewManger = [[SCViewManager alloc]init];
    NSMutableArray *imageArr = [NSMutableArray array];
    for (CmtTopicsDataModel *mode in model.dataArr) {
        
        [imageArr addObject:mode.image];
    }
    
    [self.scrollViewManger viewRepeatScrollWithPicArray:imageArr view:self.contentView frame:CGRectMake(0, 50, kWidth, self.contentView.frame.size.width / 3 ) withImageViewFrame:CGRectMake(0, 0,self.contentView.frame.size.width / 3, self.contentView.frame.size.width / 3)];
    
    __block CmtRecTableViewCell *blockSelf = self;
    self.scrollViewManger.block = ^(int index){
    
        blockSelf.tapIndexBlock(index);
    
    };

}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
